         PHP
             1 
                  .       World Wide Web (WWW).          ,      .             ,  .     , ,       web-. ,      ,     ,        .        ,       ,    ,       . ,        ,         .  ,           Linux/UNIX  Windows      HTML.        ,         . ,  ,       .     ,         , -    .       1995 ,   -     (Rasmus Lerdorf)   Perl/CGI     ,    .     :         web-.  WWW   ,         ,        .      ,  Personal Home Page ()  Hypertext Processor ( ).           .     ,    HTML,   ,       .    ,        Perl  .         2.0,  PHP-FI (Personal Home Page  Form Interpretator).    2.0      .      ,      .          HTML      ,      3.0.     3.0  1997   50 000       web-.  1997   ,       Personal Home page,   Hypertext Processor         .      ,     .   1999   Netcraft (http://www.netcraft.com)   , ,   ,     1 000 000,             .   1999        4.0.          ,     ,        .            ,     Zend (http://www.zend.com).      22  2000     4.0.    Zend,  Zend Technologies ()   Zend,          Zend.  ,           40  100 %.       Zend.     ,   Netcraft (http://www.netcraft.com),         3,6  .    ,         web-,      .             Web,        web-.          ,           ,     Perl, Java  C++.        ,     , -        .   ,    ,    web- (  HTML),            ,     JavaScript, , WML (Wireless Markup Language)    .            ,      .           ,  ,       ,  XML (Extensible Markup Language), ODBC (Open Database Connectivity)  Macromedia Shockwave.              ,           .        ,      HTML-,             HTML.  HTML       .      : <html> <title><? print "Hello world!"; ?></title> </html>  "Hello world!"    web-.  ,   print  ,       (<?...?>),    .    ,          ,     ! ,              .         /Apache  .       ,    ,       .       ,      .     .    , ,  ,        .            .       : ; ; ; ; .    ,     :   !      ,    .       Perl,        ,        Pascal.        .       10 000            ,       . . 1.1.      , ?  ,        .      ,          .     .  /Apache    ,       ,      web-   .      web-,  ,    Apache  -,    web-   , -,      . ,       web-   .                 .         http://www.php.net.         :   Win32;  .   Win32    Windows 95/98/ NT/2000.         Windows,     . ,      (,      ),    Visual C++    .       http://www.php.net/ version4/win32build.php.    Win32     .         .        ,      . ,  ,      RPM (RedHat Package Manager)? , ,         .              .     .    http://www.php.net      ,      .        .  ,    .       .           4.0.3. ,    ,     .        .       Apache,       .     http://www.apache.org/dist/binaries,      .  ,   .          web-     ,       Apache.   ,  web-   ,     ,  ,         ,    .          .        ,      .     ,          Win32    .          MySQL,           web-   .     ,     MySQL (http://www.mysql.com). MySQL,   ,     Windows    .    MySQL     , ,       11,         MySQL.    ,          Apache.      .  ,    Windows,   :   CGI,   Apache    Apache.  ,          CGI.  ,         ,            .         ,             Apache,  ,          ,  .     Windows         CGI,    Apache.         CGI,    Windows    Apache  web- (, Microsoft Internet Information Server  Microsoft Personal Web Server). CGI-     .       /Apache,     web-    .   , 4   web-,    AOL Server, Netscape Enterprise Server, Microsoft IIS, Zeus   . ,       Apache.     ,      ,       http://www.php.net. ,     Windows   ,    ,     .      :   : gunzip apache_1.3.9.tar.gz gunzip php-4.0.0.tar.gz        *.tar.     : tar -zxvf apache_1.3.x.tar tar -zxvf php-4.0.x.tar       .  Apache      Apache   .      :    Apache: cd apache_1.3.x  Apache.     ,  ,        : ./configure -prefix=[]    ; ,    .  -with-config-file-path  ,       .       /usr/local/lib,         : ./configure -with-apache=../apache_1.3.x -with-config-file-path=[] make make install    Apache.     ,    Apache.  -other-configuration-options      ,      web- Apache.      .       Apache: ./configure -activate-module=src/modules/php4/libphp4.a -other-configuration-options make make install       Apache httpd.conf.     Apache,    ,       web-.    : ServerName new.host.name     : ServerName localhost    #AddType application/x-httpd-php .php .php4 #AddType application/x-httpd-php-source .php .phps         ,    .       (#)    .           .   Apache  : ./bin/apachectl start Voila! PHP  Apache   .         phpinfo.php     Apache   htdocs,     Apache: <? php info(); ?>      .         .        Apache.   Apache    ,         web-. Apache           ModuleRewrite  ModuleSpelling.      ,           , . ,      /    ,         web-.    :    Apache: cd apache_1.3.x  Apache.     ,  ,        .  -other-configuration-options      ,      web- Apache.      .       Apache. ./configure -prefix=[] -enable-module=so -other-configuration-options   Apache.    make     : make   Apache.    make install      .         : make install      ,      httpd.conf.      conf ,    2.         ServerName new.host.name     : ServerName local host    ,    . ,    .      ,   apxs,   bin ,        2: ./configure -with-apxs=[/k/apxs] make make install   Apache httpd.conf   .                   ,      Apache, httpd.conf.   ,      ;        .   httpd.conf    .        : #AddType application/x-httpd-php .php .php4 #AddType application/x-httpd-php-source .php .phps         ,    .    '  (#)    .            ( cd).  Apache  : ./bin/apachectl start Voila!   Apache   .         phpinfo.php     Apache   htdocs,     Apache: <? php_info(): ?>      .         .         Apache.   Windows 95/98/NT   -        Windows, ,       .     ,        .        Apache       Windows.       Apache.   ,         (wizard) .        .           (C:\Program Files\Apache Group\Apache). ,      C:\Apache   .      ,         (Start).         .      .   Typical ( ).      ,  .      httpd.conf,    conf ,    2.         ServerAdmin yourname@yoursite.com  yourname@yoursite.com  .      (  ,   localhost): ServerName localhost  Apache    ,    .     ,     .    Windows NT,     (Start)  Install Apache as Service (NT Only).    ,    (Services),  Apache      (Start). Apache          .  ,   ,    http: /local host/.        ,     .     .   ,    ,      .   ,      ,      php.ini-dist.    php.ini     C:\Windows.         , php4ts.dll  Mscvrt.dll.      C:\Windows\System\. ,  Mscvrt.dll         ,  .    Apache http.conf      .     .   ScriptAlias /cgi-bin/ "C:/Apache/cgi-bin/"      : ScriptAlias /php4/ "C:/php4/"   AddType.     : #AddType application/x-httpd-php3. phtml #AddType application/x-httpd-php3-source .phps      : AddType application/x-httpd-php .phtml .php AddType application/x-httpd-php-source .phps        : # # Action lets you define media types that will execute a script whenever # a matching file is called. This eliminates the need for repeated URL # pathnames for oft-used CGI file processors. # Format: Action media/type /cgi-script/location # Format: Action handler-name /cgi-script/location #      : Action application/x-httpd-php /php4/php.exe   Apache   .         phpinfo.php     Apache   htdocs.     ,      2: <? php_info(); ?>     ,  ,    web-    ,    ,   web-    World Wide Web.          Apache (http://www.apache.org).  ,        , ,      ,      .        л.                .         ,   ,      ,       .       php.ini,       /usr/local/lib/   .     web-,     ,  php.ini     ,      .     ,       .   php.ini    .   3.0    php3.ini,    4.0     php.ini. 
            ,          .        . short_open_tag [on | off]  short_open_tab [on | off]      <?...?>    . asp_tags [on | off]  asp_tags [on | off]       ASP    .      ASP      : <% print "This is  code."; %> precision [integer]  precision [integer]    ,    . safe_mode [on | off]      ,       .    ,                 ,  passwd   Linux.  safe_mode    CGI- .          16. max_execution_time [integer]  max_execution_time [integer]        .        ,  . error_reporting [1-8]  error_reporting [1-8]        .   ,      .   1   2   4    8  display_errors [on | off]  display_errors[on | off]       . log_errors  log_errors ,      .    log_errors ,    ,     error_log. error_log [filename]  error_log  ,        log_errors. magic_quotes_gpc    magic_quotes_gpc   ,       ,     . ,  g  get/post/cookie.   ,   magic_quotes_gpc        .      ,      .   magic_quotes_gpc ,        ;        . track_vars  track_vars       ,    $HTTP_GET_VARS[], $HTTP_POST_VARS[], $HTTP_POST_FILES, $HTTP_COOKIE_VARS[], $HTTP_ENV_VARS[]  $HTTP_SERVER_VARS[].       13. ,       .     ,     .       .          ,    ,     ,   .        -       .       л (escaping to ).       :  ;  ;  script;    ASP.          ,        : <?php print "Welcome to the world of PHP!": ?>        :    <?   php,     .           ,  JavaScript,    .  ,     ?>,    .            : <? print "Welcome to the world of PHP!"; ?>      ,    .     :   -enable-short-tags   ;   short_open_tag   php.ini.  script          HTML (    ),     web-.     script: <script language="php"> <?php print "Welcome to the world of PHP!"; ?> </script>    ASP             ASP (Active Server Page).     ,  ,        (%): <%php print "Welcome to the world of PHP!"; %>     ASP   ,    .         print    (=),         ASP,        : <%=$variable %>          <% //    $recipe $recipe = "Lasagna": %> Luigi's favorite recipe is <%=$recipe;%>       .     $recipe   "Lasagna". ,     $i,         ASP. ,        (<?...?>).  HTML         HTML          , HTML  JavaScript (.  1.2).  1.2.   HTML   <html> <head> <title>Basic PHP/HTML integration</title> </head> <body> <? //      HTML   print. print "<h3>PHP/HTML integration is cool.</h3>"; ?> </body> </html> . 1.2.       date()   1.2 ,   HTML     .            (<h3>...</h3>).            HTML.   1.3      web-         (. 1.2).  1.3.    <title>PHP Recipes | <? print (date("F d, Y")); ?></title>    date()       .      .       HTML        ,   .   1.4         (h3)  $big_font       .  1.4.   HTML <html> <head> <title>PHP Recipes | <? print (date("F d, Y")); ?></title> </head> <? $big_font = "h3"; ?> <body> <? print "<$big_font>PHP Recipes</$big_font>"; ?> </body> </html>  1.4     1.3       (<h3>...</h3>)   ,        print.            HTML.            web-        ( 1.5).  1.5.        <html> <head> <title> <? print "Another PHP-enabled page"; Svariable = "Hello World!"; ?> </title></head> <body> <? print Svariable; ?> </body> </html>  1.5    (  )  HTML.     ,       ,        .              .      :         ,    .              .                 .     .          .     ,       .           (//),        (#).     : <? //    $rose_color = "red"; #    $violet_color = "blue"; print "Roses are $rose_color, violets are $violet_color" ?> ,           ,     : <? // : example. php // : .. // : 24  2000 . print "An example with comments"; ?>         ,   .               /*  */. <? /* 
: multi_coramment_example.php 
 :     
: .. 
: 14  2000 . */ print "A multiline comment can be found at the top of this script!"; ?>  ,                .          :    ;   ;   ;   .        ,           .          ,    .          ,        web-.        web-  Recipes.
  PHP ( 2)
 2              ,        .       :  ;  ; ; ; ;  .          .     ,     ( ).        .                .   : 5 591 52             (  8)   (  16)  .      0,       0  7. : 0422 0534      0  0       0  9     ()  f (F). : 0x3FF 0x22abc     (   )      .     ,   ,  ,    .      :    () .            ,  . : 12.45 98.6                ,     . : 8 5.973624    (string)   ,     ,        .  : thesaurus 49ers abc &%/$#  :       .         ,      .                   (" ")   (' ').       . -,    ,   ,   ,      ,       ,      : $food = "meatloaf"; $food = 'meatloaf';      : $sentence = "My favorite food is $food"; $sentence2 = 'My favorite food is $food';  $sentence   My favorite food is meatloaf.  :  $food  .   ,  $sentence2   My favorite food is $food.     $sentence,  $sentence2     $food.          $sentence  $sentence2.        ,      ,     ,    .  ,       ,      (,     ),   . 2.1.  2.1.       \n   
\r   
\t   \\    
\$   \"  \[0-7]{1,3}    (   ) 
\x[0-9A-Fa-f]{l,2}    (   )      ,   ,   ,     ,   ,   ,     \\  \.        ,     : $double_list = "item1\nitem2\nitem2"; $single_list = 'item1\nitem2\nitem2';      , ,         ,       \n    .       ,          .   ,     ,      .        ,   HTML4,    (here doc).         <<<,        ,  ,  .       . : $paragraph = <<<DELIM This is a string that Will be interpreted exactly As it is written in the variable assignment, DELIM;        .  ,          ,  .                   (.  ). : $sequence_number = "04efgh"; $letter = Ssequence_number[4];  $ letter    g.      ,        0. ,  $sequence_number[l]   4.       .    ,     .         .      ,       ,    . ,          .        .             ,    .     : $[1];     : $meat[0] = "chicken"; $meat[l] = "steak"; $meat[2] = "turkey";    : print $meat[1]:     steak        array ().  $meat      $meat = rr("chicken", "steak", "turkey");    pri nt         steak.       ,         . ,  $meat     : Smeat[] = "chicken"; $meat[] = "steak"; Smeat[] = "turkey";         ,       ,    . ,          .         /  ,     .       : Spairings["zinfandel"] = "Broiled Veal Chops"; $pairings["merlot"] = "Baked Ham"; $pairings["sauvignon"] = "Prime Rib"; $pairings["sauternes"] = "Roasted Salmon";         ,      . ,   ,       .         $pairings: print $pairings["merlot"]; //   "Baked Ham"        (): Spairings = rr( zinfandel => "Broiled Veal Chops", merlot => "Baked Ham", sauvignon => "Prime Rib", sauternes => "Roasted Salmon");      pairings,      .          ,     ,         .      ,            3.     : $[1][2]..[N];       : $position = $chess_board[5][4];           (   ). ,   $irings          ,     .     : $pairings["Martinelli"]["zinfandel"] = "Broiled Veal Chops"; $pairings["Beringer"]["merlot"] = "Baked Ham"; $pairings["Jarvis"]["sauvignon"] = "Prime Rib"; $pairings["Climens"]["sauternes"] = "Roasted Salmon";         (  ). ,                  .     : $Buckeyes["quarterback"] [1] = "Bellisari"; $Buckeyes["quarterback"] [2] = "Moherman": $Buckeyes["quarterback"] [3] = "Wiley";                 ,    .          13.        .    ,      ,  .         -  ().      ,    ,    .  ,        ,             . ,      ,    .          : class appliance { var power: function set_power($on_off) { $this->power = $on_off; } } ... $blender = new appliance;      ,              appliance ().        power ().       set_power. :      ,        ;        .       new. ,       $blender  appliance.    $blender        set_power: $blender->set_power("on"); -         ,        .        6.   (/)       :  (true)   (false).     :        .    .     .        =    if. : if ($sum == 40) : ...     ,  :  $sum   40,   .   $sum  40,    .      false.            . : $flag = TRUE; if ($flag == TRUE) : print "The flag is true!"; else : print "The flag is false!"; endif;   $flag ,   ,      .               1  0 .       : $flag = 1; if ($flag == TRUE) ; print "The flag is true!"; else : print "The flag is false!"; endif; ,    : $flag = TRUE: //      //   "if ($flag == TRUE)" if ($flag) : print "The flag is true!"; else : print "The flag is false!"; endif:       ,    ,  .      :              .     , ,     ASCII-    127  255. :     my_function This&that Size !counter _someword 4ward     . ,    $recipe      $Recipe, $rEciPe  $recipE.    .  ,          .      -     .   ,  ,   ,       .              .      .        ,  ,         .       , $.      : $lr $operating_system $_some_variable $model       ,   .  ,            ,  ,    ASCII-    127  255.  ,    ,     Perl,    .          .  ,          .   : $sentence = "This is a sentence."; // $sentence    $price = 42.99: // $price     $weight = 185; // $weight            ,      ,      .      (scope)        ,     .           :
 ;  ;  ;  .   ,   ,  ;  ,        .          ,      ( )  ,   .    ,      ,      .         ,        .   : $ = 4; function assignx () { $ = 0; print "\$x inside function is $x. <br>"; } assignx(); print "\$x outside of function is $x. <br>";       : $ inside function is 0. $ outside of function is 4.  ,       $.   ,   $   assignx   ,         ,     .      $           assignx().    ,       ,  ,    ,      .    ,  ,       .        .         : //      10    function x10 ($value) { $value = $value * 10; return $value; }         ,     ,      ,     .    ,    ,     .      ,         .         GLOBAL. : $somevar = 15; function addit() { GLOBAL $somevar; $somevar++; print "Somevar is $somevar"; } addit();    $somevar,  16. ,     : GLOBAL $somevar;    $somevar    1,           addit( ).      0,      1;  ,    1.           $GLOBALS( ).              $somevar: $somevar = 15; function addit() { $GLOBALS["somevar"]; $somevar++; } addit(); print "Somevar is $somevar";        , ,          ,    .  ,     ,     .        .    ,        ,        .           STATIC: STATIC $somevar;  : function keep_track() { STATIC $count = 0; $count++; print $count; print "<br>"; } keep_track(); keep_track(); keep_track();       ?    $count     (   ),    : 1 1 1    $count  ,         ,    : 1 2 3            ,         .      4.        ,     . ,      "15"    12.  ,           .  ,   ,      ,   (juggling) .       . ,         .   ,    ?     . ,            : $variablel = 1; $variable2 = "1"; $variable3 = $variablel + $variable2; // $variable3  4.          .        ,    : $variablel = 3; $variable2 = 5.4; $variable3 = $variablel + $variable2; // $variablel    . //  $variable3  8.4.        .         ,   ,     ?   : $variablel = 5; $variable2 = "100 bottles of beer on the wall"; $variable3 = ;variable1 + $variable2; // $variable3  105    ;variable3   105.   - ,         . ,    $variable2   "There are 100 bottles of beer on the wall".        ,    0,   $variable3  5.         ,        .      .       ,   ,     ,   (casting) .      , ,   .       ,                (. 2.2).  2.2.          
(int)  (integer)   (real), (double)  (float)   (string)  (array)  (object)     : $variable1= 13; // $variable1    13 $variable2 = (double) $variable1; // $variable2  13.0   $variable1     13,  (double)      (  13   13.0).     $variable2.     ,          .         : $variablel = 4.0; $variable2 = 5; $variable3 = (int) $variable1 + $variable2; // $variable3 = 9  ,         : $variablel = 14.7: $variable2 = (int) $varlable1; // $variable2 = 14:           .         : $variable1 = 1114; $array1 = (array) $varable1; print $array1[0]; //   1114 ,       .    ,     scalar: $model = "Toyota"; $new_obj = (object) $model;       : print $new_obj->scalar;    ,       .   ,  ,   ,   . ,       ,         ,   1   "ciao".         ,       .        .        ,        ,   .    : $vehicle = "car"; $amount =10.23;         ,   $vehicle,   "car",   ,   $amount,   10.23.           return  : function simple () { return 5; } $return_value = simple();  simple( )     5,    .     5    $return_value.             ,   .    -    ( )   ,     .     ,    -  & (): $dessert = "cake"; $dessert2 = $Sdessert; $dessert2 = "cookies"; print "$dessert2 <br>"; //   cookies print Sdessert; //    cookies     ,    $dessert2     ,   $dessert,   $dessert2     $dessert (   ,      ).          ,         .    : $recipe = "spaghetti"; ,  "spaghetti"                   $: $$recipe = "& meatballs";     "& meatballs"    "spaghetti". ,      : print $recipe $spaghetti; print $recipe $($recipe);       "spaghetti & meatballs".        ,          .     ,         web-,    .             ,      .      web-,   ,     ,    : while (list($var,$value) = each($GLOBALS)) : echo "<BR>$var => $value"; endwhile;       .       ,     . GLOBALS => HTTP_GET_VARS => Array HTTP_COOKIE_VARS => Array HOSTSIZE => 1000 HOSTNAME => server1.apress.com LOGNAME => unstrung HISTFILESIZE => 1000 REMOTEHOST => apress.com MAIL -> /var/spool/mail/apress MACHTYPE => 1386 TERM => vt100 HOSTTYPE => i386-linux PATH => /usr/sbin:/sbin:/usr/local /bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/Java/bin HOME => /root INPUTRC => /etc/inputrc SHELL => /bin/csh USER => nobody VENDOR => intel GROUP => root HOST => server1.apress.com OSTYPE => linux PWD => /www/bin SHLVL => 3_ => /www/bin/httpd DOCUMENT_ROOT => /usr/local/apress/site.apress HTTP_ACCEPT => */* HTTP_ACCEPT_ENCODING => gzip, deflate HTTP_ACCEPT_LANGUAGE => it.en-us;q=0.5 HTTP_CONNECTION -> Keep-Alive HTTP_HOST => www.apress.com HTTP_USER_AGENT => Mozilla/4.0 (compatible; MSIE 5.0: Windows 98; CNETHomeBuild051099) REMOTE_ADOR => 127.0.0.1 REMQTE_PORT => 3207 SCRIPT_FILENAME => /usr/local/apress/site.apress/j/environment_vars.php SERVER_ADDR => 127.0.0.1 SERVER_AOMIN => admin@apress.com SERVER_NAME => www.apress.com SERVERJORT => 80 SERVER SIGNATURE => Apache/1.3.12 Server at www.apress.com Port 80 SERVER_SOFTWARE => Apache/1.3.12 (Unix) PHP/4.0.1 GATEWAY_INTERFACE => CGI/1.1 SERVER_PROTOCOL => HTTP/1.1 REQUEST_METHOD => GET QUERY_STRING => REQUEST_URI => /j/environment_vars.php SCRIPT_NAME => /j/environment_vars.php PATH_TRANSLAETD => /usr/local/apress/site.apress/j/environment_vars.php PHP_SELF => /j/environment_vars.php argv => Array argc => 0 var => argc value => argc  ,        ,    .         . ,    IP- : print "Hi! Your IP address is: $REMOTE_ADDR"; IP-     (, 208.247.106.187).  ,             .  print "Your browser is: $HTTP_USER_AGENT";    : Your browser is: Mozina/4.0 (compatible: MSIE 5.0; Windows 98: CNETHomeBuild051099)      ,    ,     ,      .          track_vars   php.ini.    4.0.3  track_vars  .     ,       .           ,  ? (3,141592)      (5280).      define( ).      ,     ( )    . ,         : define("'PI", "3.141592");      : print "The value of pi is". PI."<br>"; $pi2 - 2 * PI: print "Pi doubled equals $pi2.";      : The value of pi is 3.141592. Pi doubled equals 6.283184.         . -,       . -,    (,    2*I);     ,       .         ,          .  ,    :    (   , , , ,  ); ;  (,  );  ;  ;    ( ,  ); .         .         ,      .    3      ,        .
  PHP ( 3)
 3 ,          ,        ,   , ,    .             .       ,    Java,        .          ,   ,            .     ,   .              .     ,   ,       .      ,   .       ,    2. ,               ,      .  : $++; // $ -  $sum = $val1 + $val2; // $sum. $val1  $val2 -         ,     .     ,    ,          ,   ,         .          (.     ).  . 3.1     ,    . ,        ,   .  3.1.      ( ) -   new -    ! ~   ,   ++ --  ,  @    / * %  , ,  + - .  , ,  << >>   ,   () < <= > >= - ,   , ,    == != === <> - ,  , ,   & ^ |    AND, XOR  OR && ||    AND  OR ?:    = += *= /= .=    %= &= |= ^= <<= >>= AND XOR OR    AND, XOR  OR             : $ = 5; //    5  $ $ = "5": //    "5"  $ $sum = 50 + $some_int; //   50 + $some_int  $sum Swine = "Zinfandel"; //   "Zinfandel"  $wine $inventory++: //   $inventory  1    ,         . : $total_cost = $cqst + (Scost * 0.06): //    6-       ,       .       ,      . : $total_cost = $cost + $cost * 0.06;    : $total cost = $cost + ($cost * 0.06);   ,            .            (. . 3.1).      :   ,   .     ,   ,   . ,  $value = 3*4*5*7*2;   : $value = ((((3 * 4) * 5) * 7) * 2);    840.   ,    (*)   .          . ,  $ = 5; $value = $ - $b - $;   $c = 5; $value = ($ - ($b - $));      $value, $a, $b  $    5.   ,    (=)   .     (. 3.2)             .  ,     .  3.2.      $ + $b   $  $b $-$b   $  $b $*$b   $  $b $/$b     $  $b $ % $b     $  $b              ,  ,    . .        .        .        ,    (   )     .      . 3.3.  3.3.      $ = 5;   $  5 $ += 5;     $   $  5 $ *= 5;     $   $  5 $/=5;     $    $  5 $ .= 5;     $   $  5          .      (. 3.4)     (  ) .    :   (.)      (.=),      .          .  3.4.      $a = "abc"."def"   $    $  $b 
$ - "ghijkl" 
    $         "ghijkl"    : // $    "Spaghetti & Meatballs" $ = "Spaghetti" . "& Meatballs" // $    "Spaghetti & Meatballs are delicious" $a .= "are delicious"; ,           .          8.         (++)   (--),   . 3.5,                 1.  3.5.        ++$, $++   $   1 --$, $--   $   1  :      ,     . ,  ,   ,       .   : $inventory = 15; //  Sinventory   15 $old_inv = Sinventory--; //   $old_inv  // Sinventory.    Sinventory. $orig_iinventory = ++inventory;//   Sinventory.   //    Sinventory //  $orig_inventory.  ,           .     (. 3.6)           ,          .                (,    i f,    for  while).  3.6.      $ && $b  ,     , $aAND$b  ,     $  $b  ,        $ OR $b  ,        !$  ,   $  NOT !$a  ,   $  $ XOR $b   ,               : file_exists("filename.txt") OR print "File does not exist!";     :  filename.txt ;   : File does not exist!.     (. 3.7)         .  3.7.      $a==$b   ,  $  $b  $ != $b   ,  $  $b   $ === $b   ,  $  $b                    ,      (, $ = $b). ,     $b  $,      .     (. 3.8),    ,             .  3.8.      $a<$b  ,   $  $b $a>$b  ,   $  $b $a <= $b    ,   $    $b $a >= $b    ,   $    $b ($a-12)?5: -1     $  12,   5,       1  :         .        , ,  ,  .         .       8.             ,  .      ,           .  . 3.9         .  3.9.           2 10 5 101 10 1010 12 1100 145 10010001 1 452 012 1011000100111111101100  ,   . 3.10,      ,       .  3.10.      $&$b   ,     $  $b,    $|$   ,     $  $b,    $^$b 
  ,     $  $b,     ~$b     $b  $ << $b    $   $b,      $ >> $b    $   $b,                ,          (Randall Hyde) The Art of Assembly Language Programming,    http://webster.cs.ucr.edu/Page_asm/Page_asm.html.    ,   -   Web.             ,             .  ,     .           ,           .   $ == $b.   ,  $  $b,     .      1,      0.   : $ = 5; $b = 5; print $ == $b;     1.   $  $    ,   5,  0. if  if     ,         ,       ,  (  )   .      i f: if () {  }  if () {  } else {  }     ,     ,   .      ,       ,     .             : if ($cooking_weight < 200) { print "This is enough pasta (< 200g) for 1-2 people"; } else { print "That's a lot of pasta. Having a party perhaps?"; }         ,    : if ($cooking_weight < 100) print "Are you sure this is enough?"; elseif  elseif     if       ,     : if () {  } elseif () {  }       elself       else if.      ,       .  elself     ,      .  :  elself     ,     if  elself  . if ($cooking_weight < 200) { print "This is enough pasta (< 200g) for 1-2 people"; } elseif ($cooking_weight < 500) { print "That's a lot of pasta. Having a party perhaps?"; } } else { print "Whoa! Who are you cooking for, a football team?"; }   if   i f      .    ,     . ,        ,      ( ): //   $pasta if ($food == "pasta") { //   $cooking_weight if ($cooking_weight < 200) { print "This is enough pasta (< 200g) for 1-2 people"; } elseif ($cooking_weight < 500) { print "That's a lot of pasta. Having a party perhaps?"; } else { print "Whoa! Who are you cooking for. a football team?"; } }     ,   if      . ,       ,  ,          .                 : if ($cooking_weight < 0) { 
print "Invalid cooking weight!"; } if ( ($cooking_weight > 0) && ($cooking_weight < 200) ) { 
print "This is enough pasta (< 200g) for 1-2 people"; } elseif ( ($cooking_weight > 200) && ($cooking_weight < 500) ) { 
print "That's a lot of pasta. Having a party perhaps?"; } else { 
print "Whoa! Who are you cooking for, a football team?"; }       ,              ,       .         ,   .   ({ })   .          : if () :  else :  endif; ,     if  : if ($== $b) { print "Equivalent values!"; } if ($a == $b) : print "Equivalent values!"; endif; while  while    ()   .   while    ,     .    while  : while () :  endwhile;    while     (n!),  n = 5: $n = 5; $n = $n; $factorial = 1; //     while ($n > 0) : $factorial - $n * $factorial; $n--; //  $n  1 endwhile; print "The factorial of $ncopy is $factorial.";    : The factorial of 5 is 120.    $n     .         ,   $n   0,   $factorial   0  ,    .              $n > 1,   $factorial  1       .       ,            . do. .while  do. .while    ,    while,    ,   do. .while     ,     . ,   do. .while      ,   while    ,        : do:  while ();             do. .while: $n = 5: $ncopy = $n; $factorial = 1; //     do { $factorial = $n * $factorial; $n--: //  Sn  1 } while (Sn > 0); print "The factorial of Sncopy is $factorial.";         ,         .   do. .while     (    :    ),        . for  for       .     while  ,       ,   -   .       while,     ,     .    for  : for (: ; ) {  }    for      .            .        ,       . ,        . ,      ,     ,        .        for: for ($i = 10; $1 <- 100: $1 +=10) : //     print "\$i = $i <br>"; endfor; //    $1      : $i = 10 $i = 20 $i = 30 $i = 40 $i - 50 $i = 60 $i = 70 $i = 80 $i = 90 $i = 100      $i   10.    ,      ,  $i        100. ,     $i   10.    print  10 ,      $i.  :   $i  10     .     ,   for        $i = $i + 10. ,        ,     : for ($i = 10; $i <= 100; print "\$i - $i <br>". $i+=10);    ,        ,     -  .      ?   ,    for    . ,      ,    : for ($x=0,$y=0: $x+$y<10; $x++) : $ += 2; //  $  2 print "\$y = $y <BR>"; //   $ $sum = $x + $y; print "\surn = $sum<BR>"; //   $sum endfor; : $y = 2 $sum = 2 Sy = 4 $sum = 5 $y = 6 $sum = 8 $y = 8 $sum = 11      $y   $  $.     ,   $sum = 11,         ($ + $ < 10).   - ,        $   6,   $   2.     ,  $  $    ,       .      11    10   .     for    . ,         ,      .      ,          ,   .          . : $ = 5: for (: : $ +=2) : print " $ "; if ($x == 15) : break; //    for endif; endfor;   : 5 7 9 11 13 15    for  while    , ,   for    .   ,      for          .   ,   while                  . foreach  foreach    for,        .     foreach,     : foreach ( as $) {  } foreach ( as $ => $) {  } ,    : $menu = rr("pasta", "steak", "potatoes", "fish", "fries"); foreach ($menu as $item) { print "$item <BR>"; }    : pasta steak potatoes fish fries         . -,  foreach      (      ). -,                     foreach.        : $wine_inventory = array { "merlot" => 15, "zinfandel" => 17, "sauvignon" => 32 } foreach ($wine_inventory as $i => $item_count) { print "$item_count bottles of $i remaining<BR>"; }      : 15 bottles of merlot remaining 17 bottles of zinfandel remaining 32 bottles of sauvignon remaining     ,  foreach     .         5. switch    switch   if  ,    ,     .       ,   switch      .    switch: switch () { case ():  case ():  ... default:  }          switch.          case.       .     ,     default.      ,         . ,              ,     case.        switch: $user_input = "recipes"; // ,  switch ($user_input) : case("search") : print "Let's perform a search!"; break; case("dictionary") : print "What word would you like to look up?"; break; case("recipes") : print "Here is a list of recipes..."; break; default : print "Here is the menu..."; break; endswitch;     ,  switch      . ,    switch (    $user_input),       case.  ,    case,     ,    .  break     case     switch.        ,    default.   default        ,  switch         .   ,      case  break (.  )  switch       ,     break       switch.        break: $value = 0.4; switch($value) : case (0.4) : print "value is 0.4<br>"; case (0.6) : print "value is 0.6<br>"; break; case (0.3) : print "value is 0.3<br>"; break; default : print "You didn't choose a value!"; break; endswitch;   : value is 0.4 value is 0.6   break   ,       print   ,    ,    print   .     switch  -  switch,     print.    switch  if      -.            . break  break      while, for  switch,    .       ,         break.     break  : break n;   n     ,   break. ,   break     while   break   2,      .    n  1;          1,     break  .  :  i f      ,   break.         .     break   foreach: $arr = array(14, 12, 128, 34, 5); $magic number = 128: foreach ($arr as $val) : if (Sval == $magic_number) : print "The magic number is in the array!"; break; endif; print "val is Sval <br>"; endforeach;   $magic_number    $rr (   ),  .   : val is 14 val is 12 The magic number is in the array!        break.      in_array( ),        ;       5. continue         continue.    continue             .   continue   : continue n;   n ,        continue.     continue. ,         0    .   ,      is_prime(),  ,     : $boundary = 558; for ($i = 0; $i <= $boundary: $i++) : if (! is_prime($i)) : continue; endif; $prime_counter++; endfor;     ,   if    $prime_counter .      continue,          .  continue         -    .     continue  .  continue      ,         if. :       ,  ,      -.        ,        ,       .      ,    ,      ,      .            : July 21, 2000|8 p. m.|Cooking With Rasmus|PHP creator Rasmus Lerdorf discusses the wonders of cheese. July 23, 2000|11 a. m.|Boxed Lunch|Valerie researches the latest ham sandwich making techniques (documentary) July 31, 2000|2:30p.m.|Progressive Gourmet|Forget the Chardonnay: iced tea is the sophisticated gourmet's beverage of choice. August 1, 2000|7 p.m.|Coder's Critique|Famed Food Critic Brian rates NYC's hottest new Internet cafes. August 3, 2000|6 p.m.|Australian Algorithms|Matt studies the alligator's diet.  . 3.1     ,    3.1. . .1.          ,      :  ,    .     4 : , ,     .    .  .  3.1.     events.txt   <? // :  // :      //        //    Sevents   events.txt $events - fopen ("events.txt". "r"); print "<table border = 0 width = 250>" print""<tr><td valign=top"; print "<h3>Events Calendar:</h3>"; // ,       while (! feof(Sevents)) : //     events.txt $event = fgets($events. 4096); //        $event_info = explode("|". Jevent); //       print "$event_info[0] ( $event_info[1] ) <br>"; print "<b>$event_info[2]</b> <br>"; print "$event_info[3] <br> <br>"; endwhile; //   print "</td></tr></table>"; fclose ($events); ?>     ,               .  -     ,                .          ,    7  /      8            .              , , ,          .       ,  : ; ;  ;  ;   (If, while, do. .while, for, foreach, switch, break, continue).            .        ;          , - ,  /    .         ,      ,     . ,       !
